wayland: unset sequence if the xdg surface is moved/resized through touch
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 20 Aug 2014 18:23:58 +0000 (20:23 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Tue, 26 Aug 2014 11:41:05 +0000 (13:41 +0200)
The latest implicit grab serial is used in order to start the compositor
grab, If it belongs to a touch event, remove that touch sequence, as the
rest of the sequence will be gone for good.

This avoids stale sequences (and implicit grab info) after a window is
moved/resized.

https://bugzilla.gnome.org/show_bug.cgi?id=731380

gdk/wayland/gdkwindow-wayland.c

index 35062f3fd39626358f15cde5ddcf57fc3279816d..6875099d0e6fa6224127b24d88abfc59d7159da6 100644 (file)
@@ -1760,10 +1760,8 @@ gdk_wayland_window_begin_resize_drag (GdkWindow     *window,
                                       guint32        timestamp)
 {
   GdkWindowImplWayland *impl;
-  GdkWaylandDisplay *wayland_display =
-    GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
-
-  uint32_t resize_edges;
+  GdkEventSequence *sequence;
+  uint32_t resize_edges, serial;
 
   if (GDK_WINDOW_DESTROYED (window) ||
       !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
@@ -1813,10 +1811,15 @@ gdk_wayland_window_begin_resize_drag (GdkWindow     *window,
   if (!impl->xdg_surface)
     return;
 
+  serial = _gdk_wayland_device_get_last_implicit_grab_serial (GDK_WAYLAND_DEVICE (device),
+                                                              &sequence);
+
   xdg_surface_resize (impl->xdg_surface,
                       gdk_wayland_device_get_wl_seat (device),
-                      _gdk_wayland_display_get_serial (wayland_display),
-                      resize_edges);
+                      serial, resize_edges);
+
+  if (sequence)
+    gdk_wayland_device_unset_touch_grab (device, sequence);
 
   /* This is needed since Wayland will absorb all the pointer events after the
    * above function - FIXME: Is this always safe..?
@@ -1833,8 +1836,8 @@ gdk_wayland_window_begin_move_drag (GdkWindow *window,
                                     guint32    timestamp)
 {
   GdkWindowImplWayland *impl;
-  GdkWaylandDisplay *wayland_display =
-    GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
+  GdkEventSequence *sequence;
+  uint32_t serial;
 
   if (GDK_WINDOW_DESTROYED (window) ||
       !WINDOW_IS_TOPLEVEL (window))
@@ -1845,9 +1848,13 @@ gdk_wayland_window_begin_move_drag (GdkWindow *window,
   if (!impl->xdg_surface)
     return;
 
+  serial = _gdk_wayland_device_get_last_implicit_grab_serial (GDK_WAYLAND_DEVICE (device),
+                                                              &sequence);
   xdg_surface_move (impl->xdg_surface,
                     gdk_wayland_device_get_wl_seat (device),
-                    _gdk_wayland_display_get_serial (wayland_display));
+                    serial);
+  if (sequence)
+    gdk_wayland_device_unset_touch_grab (device, sequence);
 
   /* This is needed since Wayland will absorb all the pointer events after the
    * above function - FIXME: Is this always safe..?